package com.jcl.recruit.user.mapper;

import com.jcl.recruit.user.model.UserResumeAttention;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserResumeAttentionMapper {

    @Select({
            "<script>",
            "select * from user_resume_attention where user_id = #{userId} and status = 1 and search_resume_id in ",
            "<foreach collection='searchResumeIds' item='searchResumeId' open='(' close=')' separator=','>",
            "#{searchResumeId}",
            "</foreach>",
            "</script>"
    })
    List<UserResumeAttention> getListBySearchResumeIds(@Param("userId") Integer userId, @Param("searchResumeIds") List<Integer> searchResumeIds);

    @Select({
            "select * from user_resume_attention where user_id = #{userId} and status = 1"
    })
    List<UserResumeAttention> getListByUserId(@Param("userId") Integer userId);

    @Select({
            "select * from user_resume_attention where user_id = #{userId} and resume_id = #{resumeId} and status = 1 "
    })
    List<UserResumeAttention> getListByResumeId(@Param("userId") Integer userId, @Param("resumeId") Integer resumeId);

    @Select({
            "select * from user_resume_attention where user_id = #{userId} and search_resume_id = #{searchResumeId} and status = 1 "
    })
    List<UserResumeAttention> getListBySearchResumeId(@Param("userId") Integer userId, @Param("searchResumeId") Integer searchResumeId);

    @Select({
            "select * from user_resume_attention where user_id = #{userId} and apply_other_jid = #{otherJid} and status = 1 "
    })
    List<UserResumeAttention> getListByOtherJid(@Param("userId") Integer userId, @Param("otherJid") String otherJid);


    @Select({
        "select * from user_resume_attention where id = #{id}"
    })
    UserResumeAttention findOne(@Param("id") Integer id);

    @Update({
        "update user_resume_attention set status=#{status} where id = #{id}"
    })
    int update(@Param("id") Integer id, @Param("status") Integer status);

    @InsertProvider(type = UserResumeAttentionProvider.class, method = "insertSelective")
    @Options(keyProperty = "id", useGeneratedKeys = true)
    int add(UserResumeAttention attention);

}
